/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;

/**
 * <p>Project: jse2302 - LinkedListDemo
 * <p>Powered by webrx On 2023-06-25 14:02:59
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class LinkedListDemo {
    public static void main(String[] args) {

        List<Integer> ll = new Vector<>();

        System.out.println("LinkedList");
        LinkedList<String> list = new LinkedList<>();

        long ss = System.currentTimeMillis();
        for (int i = 0; i <= 100000; i++) {
            list.add(0, "LinkedList - " + i);
        }

        long ee = System.currentTimeMillis();
        System.out.println(ee - ss);

        System.out.println("ArrayList");
        ArrayList<String> arr = new ArrayList<>();
        ss = System.currentTimeMillis();
        for (int i = 0; i <= 100000; i++) {
            arr.add(0, "ArrayList - " + i);
        }
        ee = System.currentTimeMillis();
        System.out.println(ee - ss);

        System.out.println("---------------------------------");
        ss = System.currentTimeMillis();
        for (int i = 0; i <= 100000; i++) {
            list.get(i);
        }


        ee = System.currentTimeMillis();
        System.out.println(ee - ss);


        ss = System.currentTimeMillis();
        for (int i = 0; i <= 100000; i++) {
            arr.get(i);
        }
        ee = System.currentTimeMillis();
        System.out.println(ee - ss);
    }
}
